package com.hjx.service.impl;

import com.hjx.entity.SysDepartment;
import com.hjx.mapper.SysDepartmentMapper;
import com.hjx.service.SysDepartmentService;
import com.hjx.util.UUIDUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author hjx
 * @date 2020/6/11 - 10:46
 */
@Service
@Transactional
public class SysDepartmentServiceImpl implements SysDepartmentService {
    @Resource
    SysDepartmentMapper sysDepartmentMapper;
    @Override
    public SysDepartment findOne(String depId) {
        if (depId!=null){
            return sysDepartmentMapper.findOne(depId);
        }
        return null;
    }

    @Override
    public List<SysDepartment> findAll() {
        return sysDepartmentMapper.findAll();
    }

    @Override
    public boolean insert(SysDepartment sysDepartment) {
        sysDepartment.setDepId(UUIDUtil.getUUID());
        return sysDepartmentMapper.insert(sysDepartment);
    }

    @Override
    public boolean delete(String depId) {
        if (depId!=null){
            return sysDepartmentMapper.delete(depId);
        }
        return false;
    }

    @Override
    public boolean update(SysDepartment sysDepartment) {
        return sysDepartmentMapper.update(sysDepartment);
    }

    @Override
    public List<SysDepartment> findBy(SysDepartment sysDepartment) {
        return sysDepartmentMapper.findBy(sysDepartment);
    }
}
